<template>
	<div class="strategyOverallContent">
		<div class="systemParameterPageBox">
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">心跳配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">心跳频率</div>
						<div class="form_item">
							<el-select v-model="heartbeatConfig.heartbeatFrequency" placeholder="请选择" @change="handleSelect_heartbeat">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">请求配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">请求频率</div>
						<div class="form_item">
							<el-select v-model="requestConfig.requestFrequency" placeholder="请选择" @change="handleSelect_request">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">告警上报配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">告警上报</div>
						<div class="form_item">
							<el-switch v-model="waringConfig.waringState" @change="handleSwitchWaring" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端的运维日志、告警信息等的上报</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">发送频率</div>
						<div class="form_item">
							<el-select v-model="waringConfig.waringFrequency" placeholder="请选择" @change="handleSelect_waring">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">审计上报配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">审计上报</div>
						<div class="form_item">
							<el-switch v-model="auditConfig.auditState" @change="handleSwitchAudit" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端监控信息的上报</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">发送频率</div>
						<div class="form_item">
							<el-select v-model="auditConfig.auditFrequency" placeholder="请选择" @change="handleSelect_audit">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>
			<!--			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">比较频率配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">比较上报</div>
						<div class="form_item">
							<el-switch v-model="compareConfig.compareState" @change="handleSwitchCompare" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端监控信息的上报</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">发送频率</div>
						<div class="form_item">
							<el-select v-model="compareConfig.compareFrequency" placeholder="请选择" @change="handleSelect_compare">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的上报频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>-->
			<!--			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">终端监控配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">监控上报</div>
						<div class="form_item">
							<el-switch
								v-model="terminalMonitoringConfig.terminalMonitoringState"
								@change="handleSwitchTerminalMonitoring"
								active-color="#13ce66"
								inactive-color="#ff4949"
							>
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端监控信息的上报</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">发送频率</div>
						<div class="form_item">
							<el-select
								v-model="terminalMonitoringConfig.terminalMonitoringFrequency"
								placeholder="请选择"
								@change="handleSelect_terminalMonitoring"
							>
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的上报频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>-->
			<!--			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">系统日志配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">日志上报</div>
						<div class="form_item">
							<el-switch
								v-model="systemLogConfig.systemLogState"
								@change="handleSwitchSystemLog"
								active-color="#13ce66"
								inactive-color="#ff4949"
							>
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端监控信息的上报</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">发送频率</div>
						<div class="form_item">
							<el-select v-model="systemLogConfig.systemLogFrequency" placeholder="请选择" @change="handleSelect_systemLog">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的上报频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>
				</div>
			</div>-->

			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">前置装置设备状态</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">设备状态</div>
						<div class="form_item">
							<el-switch v-model="doorConfig.doorState" @change="handleSwitchDoor" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端信息的上报</div>
					</div>
					<!-- <div class="pageConfigBoxContentItem">
						<div class="form_text">告警阈值</div>
						<div class="form_item_input door_class">
							<el-input v-model="doorConfig.doorFrequency" placeholder="请输入告警阈值" v-validate="'required|pin'"></el-input>
							<wj-Button type="save" v-checksubmit="{ submitEvent: send_door, cls: 'door_class' }">确定</wj-Button>
						</div>
						<div class="form_hint">提示：更频繁的上报频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div> -->

					<div class="pageConfigBoxContentItem">
						<div class="form_text">频率</div>
						<div class="form_item">
							<el-select v-model="doorConfig.frequency" placeholder="请选择" @change="handleSelect_frequency">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：更频繁的频率可以查看更实时的数据，但也会占用网络带宽</div>
					</div>

					<div class="pageConfigBoxContentItem">
						<div class="form_text">开门距离</div>
						<div class="form_item_input door_class">
							<el-input
								ref="door_class"
								v-model="doorConfig.doorDistance"
								placeholder="请输入开门距离"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_door, cls: 'door_class' }">确定</wj-Button> -->
							<wj-Button type="save" @click="send_door">确定</wj-Button>
						</div>
						<div class="form_hint">提示：开门距离，单位mm</div>
					</div>
					<!-- <div class="pageConfigBoxContentItem">
						<div class="form_text">姿态误差</div>
						<div class="form_item_input attitudeError_class">
							<el-input
								ref="attitudeError_class"
								v-model="doorConfig.attitudeError"
								placeholder="请输入姿态误差"
								v-validate="'required|pin'"
							></el-input>
							<wj-Button type="save" @click="send_attitudeError">确定</wj-Button>
						</div>
						<div class="form_hint">提示：姿态误差，单位°</div>
					</div> -->
					<div class="pageConfigBoxContentItem">
						<div class="form_text">箱体温度阈值</div>
						<div class="form_item_input temperatureThreshold_class">
							<el-input
								ref="temperatureThreshold_class"
								v-model="doorConfig.temperatureThreshold"
								placeholder="请输入箱体温度阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_temperatureThreshold, cls: 'temperatureThreshold_class' }"
								>确定</wj-Button
							> -->
							<wj-Button type="save" @click="send_temperatureThreshold">确定</wj-Button>
						</div>
						<div class="form_hint">提示：箱体温度告警阈值，单位°C</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">箱体湿度阈值</div>
						<div class="form_item_input humidityThreshold_class">
							<el-input
								ref="humidityThreshold_class"
								v-model="doorConfig.humidityThreshold"
								placeholder="请输入箱体湿度阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_humidityThreshold, cls: 'humidityThreshold_class' }"
								>确定</wj-Button
							> -->
							<wj-Button type="save" @click="send_humidityThreshold">确定</wj-Button>
						</div>
						<div class="form_hint">提示：箱体湿度告警阈值，单位%RH</div>
					</div>

					<div class="pageConfigBoxContentItem">
						<div class="form_text">cpu</div>
						<div class="form_item_input humidityThreshold_class">
							<el-input
								ref="humidityThreshold_class"
								v-model="doorConfig.cpuRange"
								placeholder="请输入cpu阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_humidityThreshold, cls: 'humidityThreshold_class' }"
								>确定</wj-Button
							> -->
							<wj-Button type="save" @click="update_CpuRange">确定</wj-Button>
						</div>
						<div class="form_hint">提示：cpu阈值，当前cpu超过此值为异常，单位%</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">磁盘</div>
						<div class="form_item_input humidityThreshold_class">
							<el-input
								ref="humidityThreshold_class"
								v-model="doorConfig.diskRange"
								placeholder="请输入湿度阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_humidityThreshold, cls: 'humidityThreshold_class' }"
								>确定</wj-Button
							> -->
							<wj-Button type="save" @click="update_DiskRange">确定</wj-Button>
						</div>
						<div class="form_hint">提示：磁盘阈值，当前内存超过此值为异常，单位%</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">内存</div>
						<div class="form_item_input humidityThreshold_class">
							<el-input
								ref="humidityThreshold_class"
								v-model="doorConfig.memoryRange"
								placeholder="请输入内存阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_humidityThreshold, cls: 'humidityThreshold_class' }"
								>确定</wj-Button
							> -->
							<wj-Button type="save" @click="update_MemoryRange">确定</wj-Button>
						</div>
						<div class="form_hint">提示：内存阈值，单位%</div>
					</div>
					<div class="pageConfigBoxContentItem">
						<div class="form_text">前置装置CPU运行温度</div>
						<div class="form_item_input humidityThreshold_class">
							<el-input
								ref="humidityThreshold_class"
								v-model="doorConfig.cpuTemptureRange"
								placeholder="请输入前置装置运行温度阈值"
								v-validate="'required|pin'"
							></el-input>
							<!-- <wj-Button type="save" v-checksubmit="{ submitEvent: send_humidityThreshold, cls: 'humidityThreshold_class' }"
                >确定</wj-Button
              > -->
							<wj-Button type="save" @click="update_CpuTemptureRange">确定</wj-Button>
						</div>
						<div class="form_hint">提示：前置装置运行温度阈值，单位°C</div>
					</div>
				</div>
			</div>
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">SIM卡上报配置</div>
				</div>
				<div class="pageConfigBoxContent">
					<!--					<div class="pageConfigBoxContentItem">
						<div class="form_text">VPN上报</div>
						<div class="form_item">
							<el-switch v-model="VPNConfig.VPNState" @change="handleSwitchVPN" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</div>
						<div class="form_hint">提示：开启后方可收到安全终端监控信息的上报</div>
					</div>-->
					<div class="pageConfigBoxContentItem">
						<div class="form_text">频率</div>
						<div class="form_item">
							<el-select v-model="VPNConfig.VPNFrequency" placeholder="请选择">
								<el-option key="24小时" label="24小时" value="24小时"> </el-option>
								<!--								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>-->
							</el-select>
						</div>
						<div class="form_hint">提示：此为SIM卡监测频率</div>
					</div>
				</div>
			</div>

			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">短信审批配置</div>
				</div>
				<div class="pageConfigBoxContent">
          <div class="pageConfigBoxContentItem">
            <div class="form_text">开启短信审批</div>
            <div class="form_item">
              <el-switch v-model="smsConfig.smsState" @change="handleSmsSwitch" active-color="#13ce66" inactive-color="#ff4949">
              </el-switch>
            </div>
            <div class="form_hint">提示：开启后，将允许发布管理员通过手机短信回复的方式，实现发布内容的审批</div>
          </div>
				</div>
<!--				<div class="pageConfigBoxContent">-->
<!--          <div class="pageConfigBoxContentItem">-->
<!--            <div class="form_text">开启智能短信审批</div>-->
<!--            <div class="form_item">-->
<!--              <el-switch v-model="smsConfig.smartAudit" @change="handleSmartAudit" active-color="#13ce66" inactive-color="#ff4949">-->
<!--              </el-switch>-->
<!--            </div>-->
<!--            <div class="form_hint">提示：开启后，将允许系统将发布内容发给百度智能审核平台进行审核，实现智能审核审批</div>-->
<!--          </div>-->
<!--				</div>-->
			</div>

      <div class="pageConfigBox">
        <div class="pageConfigBoxTitle">
          <div class="titleText">时间服务器配置</div>
        </div>
        <div class="pageConfigBoxContent">
          <div class="pageConfigBoxContentItem">
            <div class="form_text">服务器ip/域名</div>
            <div class="form_item_input door_class">
              <el-input
                  ref="door_class"
                  v-model="ntpConfig.ntpAddress"
                  placeholder="请输入时间服务器地址"
                  v-validate="'hostAndEmpty'"
              ></el-input>
              <wj-Button type="save" @click="send_ntp">确定</wj-Button>
            </div>
            <div class="form_hint">提示：此为时间服务器配置项</div>
          </div>
        </div>
      </div>
		</div>
	</div>
</template>
<script>
import {
  system_parameter_all,
  system_parameter_heart,
  system_parameter_request,
  system_parameter_waring,
  system_parameter_waringState,
  system_parameter_audit,
  system_parameter_auditState,
  system_parameter_compare,
  system_parameter_compareState,
  system_parameter_terminalMonitoring,
  system_parameter_terminalMonitoringState,
  system_parameter_systemLog,
  system_parameter_systemLogState,
  overall_doorState,
  overall_doorDistance,
  overall_attitudeError,
  overall_temperatureThreshold,
  overall_humidityThreshold,
  system_parameter_VPN,
  system_parameter_VPNState,
  system_update_CpuRange,
  system_update_DiskRange,
  system_update_MemoryRange,
  system_update_CpuTemptureRange,
  system_parameter_SmsState,
  system_parameter_ntpServerHost,
  system_parameter_SmartAudit,
} from "@/utils/request/api";
export default {
	name: "StrategyOverall",
	data() {
		return {
			// 下拉数据（下拉时间）
			options: [
				{
					value: "5秒",
					label: "5秒",
				},
				{
					value: "10秒",
					label: "10秒",
				},
				{
					value: "30秒",
					label: "30秒",
				},
				{
					value: "60秒",
					label: "60秒",
				},
				{
					value: "5分钟",
					label: "5分钟",
				},
				{
					value: "10分钟",
					label: "10分钟",
				},
				{
					value: "30分钟",
					label: "30分钟",
				},
				{
					value: "1小时",
					label: "1小时",
				},
				{
					value: "6小时",
					label: "6小时",
				},
				{
					value: "12小时",
					label: "12小时",
				},
				{
					value: "24小时",
					label: "24小时",
				},
			],
			// 心跳配置
			heartbeatConfig: {
				heartbeatFrequency: "",
			},
			// 请求配置
			requestConfig: {
				requestFrequency: "",
			},
			// 告警上报配置
			waringConfig: {
				waringState: false,
				waringFrequency: "",
			},
			// 审计上报配置
			auditConfig: {
				auditState: false,
				auditFrequency: "",
			},
			// 比较上报配置
			compareConfig: {
				compareState: false,
				compareFrequency: "",
			},
			// 终端监控配置
			terminalMonitoringConfig: {
				terminalMonitoringState: false,
				terminalMonitoringFrequency: "",
			},
			// 系统日志配置
			systemLogConfig: {
				systemLogState: false,
				systemLogFrequency: "",
			},
			// 开关门配置/工控设备状态
			doorConfig: {
				doorState: false,
				// doorFrequency: "",
				frequency: "",
				doorDistance: "",
				attitudeError: "",
				temperatureThreshold: "",
				humidityThreshold: "",

				cpuRange: "",
				memoryRange: "",
				diskRange: "",
				cpuTemptureRange: "",
			},
			// VPN配置
			VPNConfig: {
				VPNState: false,
				VPNFrequency: "",
			},
      // SMS 短信审批配置
      smsConfig:{
        smsState: true,
        smartAudit: false
      },
      // NTP 时间服务器配置
      ntpConfig: {
        ntpAddress: "",
      }
		};
	},
	create() {},
	mounted() {
		this.getAllParameter();
	},
	methods: {
		//cpu
		update_CpuRange() {
			system_update_CpuRange({
				cpuRange: this.doorConfig.cpuRange,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("cpu阈值配置成功！");
				} else {
					this.$msg.error("cpu阈值配置失败！");
				}
			});
		},
		// 磁盘
		update_DiskRange() {
			system_update_DiskRange({
				diskRange: this.doorConfig.diskRange,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("磁盘配置成功！");
				} else {
					this.$msg.error("磁盘配置失败！");
				}
			});
		},
		// 内存
		update_MemoryRange() {
			system_update_MemoryRange({
				memoryRange: this.doorConfig.memoryRange,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("内存阈值配置成功！");
				} else {
					this.$msg.error("内存阈值配置失败！");
				}
			});
		},
		// cpu温度
		update_CpuTemptureRange() {
			system_update_CpuTemptureRange({
				cpuTemptureRange: this.doorConfig.cpuTemptureRange,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("cpu温度阈值配置成功！");
				} else {
					this.$msg.error("cpu温度阈值配置失败！");
				}
			});
		},
		// 频率
		handleSelect_frequency() {
			console.log(this.doorConfig.frequency);
			system_parameter_terminalMonitoring({
				monitorFrequency: this.transitionSelectTime(this.doorConfig.frequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("前置装置设备状态频率配置成功！");
				} else {
					this.$msg.error("前置装置设备状态频率配置失败！");
				}
			});
		},
		// 心跳
		handleSelect_heartbeat() {
			console.log(this.heartbeatConfig.heartbeatFrequency);
			console.log(this.transitionSelectTime(this.heartbeatConfig.heartbeatFrequency));
			system_parameter_heart({
				heart: this.transitionSelectTime(this.heartbeatConfig.heartbeatFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("心跳频率修改成功！");
				} else {
					this.$msg.error("心跳频率修改失败！");
				}
			});
		},
		// 请求
		handleSelect_request() {
			console.log(this.requestConfig.requestFrequency);
			console.log(this.transitionSelectTime(this.requestConfig.requestFrequency));
			system_parameter_request({
				requestFrequency: this.transitionSelectTime(this.requestConfig.requestFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("请求频率修改成功！");
				} else {
					this.$msg.error("请求频率修改失败！");
				}
			});
		},
		// 告警上报
		handleSwitchWaring(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_waringState({
				warnningStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("告警上报配置成功！");
				} else {
					this.$msg.error("告警上报配置失败！");
				}
			});
		},
		handleSelect_waring() {
			console.log(this.waringConfig.waringFrequency);
			console.log(this.transitionSelectTime(this.waringConfig.waringFrequency));
			system_parameter_waring({
				warningFrequency: this.transitionSelectTime(this.waringConfig.waringFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("告警上报发送频率修改成功！");
				} else {
					this.$msg.error("告警上报发送频率修改失败！");
				}
			});
		},
		// 审计上报
		handleSwitchAudit(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_auditState({
				auditStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("审计上报配置成功！");
				} else {
					this.$msg.error("审计上报配置失败！");
				}
			});
		},
		handleSelect_audit() {
			console.log(this.auditConfig.auditFrequency);
			console.log(this.transitionSelectTime(this.auditConfig.auditFrequency));
			system_parameter_audit({
				auditFrequency: this.transitionSelectTime(this.auditConfig.auditFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("审计上报发送频率修改成功！");
				} else {
					this.$msg.error("审计上报发送频率修改失败！");
				}
			});
		},
		// 比较上报
		handleSwitchCompare(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_compareState({
				compareStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("比较上报配置成功！");
				} else {
					this.$msg.error("比较上报配置失败！");
				}
			});
		},
		handleSelect_compare() {
			console.log(this.compareConfig.compareFrequency);
			console.log(this.transitionSelectTime(this.compareConfig.compareFrequency));
			system_parameter_compare({
				compareFrequency: this.transitionSelectTime(this.compareConfig.compareFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("比较上报发送频率修改成功！");
				} else {
					this.$msg.error("比较上报发送频率修改失败！");
				}
			});
		},
		// 终端监控
		handleSwitchTerminalMonitoring(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_terminalMonitoringState({
				monitoringStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("终端监控配置成功！");
				} else {
					this.$msg.error("终端监控配置失败！");
				}
			});
		},
		handleSelect_terminalMonitoring() {
			console.log(this.terminalMonitoringConfig.terminalMonitoringFrequency);
			console.log(this.transitionSelectTime(this.terminalMonitoringConfig.terminalMonitoringFrequency));
			system_parameter_terminalMonitoring({
				monitorFrequency: this.transitionSelectTime(this.terminalMonitoringConfig.terminalMonitoringFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("终端监控发送频率修改成功！");
				} else {
					this.$msg.error("终端监控发送频率修改失败！");
				}
			});
		},
		// 系统日志
		handleSwitchSystemLog(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_systemLogState({
				pcsyslogStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("系统日志配置成功！");
				} else {
					this.$msg.error("系统日志配置失败！");
				}
			});
		},
		handleSelect_systemLog() {
			console.log(this.systemLogConfig.systemLogFrequency);
			console.log(this.transitionSelectTime(this.systemLogConfig.systemLogFrequency));
			system_parameter_systemLog({
				pcSyslogFrequency: this.transitionSelectTime(this.systemLogConfig.systemLogFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("系统日志发送频率修改成功！");
				} else {
					this.$msg.error("系统日志发送频率修改失败！");
				}
			});
		},
		// 开关门
		handleSwitchDoor(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			overall_doorState({
				devStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("前置装置设备配置成功！");
				} else {
          this.$msg.error("前置装置设备配置失败！");
        }
      });
    },
    handleSmsSwitch(newValue) {
      system_parameter_SmsState({
        smsStatus: newValue ? 0 : 1,
      }).then((res) => {
        if (res.code === 200) {
          this.$msg.success("短信审批配置成功！");
        } else {
          this.$msg.error("短信审批配置失败！");
        }
      });
    },
    handleSmartAudit(newValue) {
      system_parameter_SmartAudit({
        smartAudit: newValue ? 0 : 1,
      }).then((res) => {
        if (res.code === 200) {
          this.$msg.success("智能审批配置成功！");
        } else {
          this.$msg.error("智能审批配置失败！");
        }
      });
    },
		send_door() {
			console.log(this.doorConfig.doorDistance);
			this.$nextTick(() => {
				this.$refs.door_class.focus();
				this.$refs.door_class.blur();
			});
			overall_doorDistance({
				doorRange: this.doorConfig.doorDistance,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("开关门距离修改成功！");
				} else {
					this.$msg.error("开关门距离修改失败！");
				}
			});
		},
		send_attitudeError() {
			console.log(this.doorConfig.attitudeError);
			this.$nextTick(() => {
				this.$refs.attitudeError_class.focus();
				this.$refs.attitudeError_class.blur();
			});
			overall_attitudeError({
				angleRange: this.doorConfig.attitudeError,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("姿态误差修改成功！");
				} else {
					this.$msg.error("姿态误差修改失败！");
				}
			});
		},
		send_temperatureThreshold() {
			console.log(this.doorConfig.temperatureThreshold);
			this.$nextTick(() => {
				this.$refs.temperatureThreshold_class.focus();
				this.$refs.temperatureThreshold_class.blur();
			});
			overall_temperatureThreshold({
				temptureRange: this.doorConfig.temperatureThreshold,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("温度阈值修改成功！");
				} else {
					this.$msg.error("温度阈值修改失败！");
				}
			});
		},
		send_humidityThreshold() {
			console.log(this.doorConfig.humidityThreshold);
			this.$nextTick(() => {
				this.$refs.humidityThreshold_class.focus();
				this.$refs.humidityThreshold_class.blur();
			});
			overall_humidityThreshold({
				rhRange: this.doorConfig.humidityThreshold,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("湿度阈值修改成功！");
				} else {
					this.$msg.error("湿度阈值修改失败！");
				}
			});
		},
    send_ntp(){
      this.ntpConfig.ntpAddress = this.ntpConfig.ntpAddress.trim();
      let inputValue = this.ntpConfig.ntpAddress;
      let hostRule = /(?!:\/\/)(?:[-\w]+\.){1,126}(?:[-\w]+\.)+[a-z]{2,}(?::\d+)?/;
      let ipAddrRule = /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/;
      if (hostRule.test(inputValue) || ipAddrRule.test(inputValue)) {
        system_parameter_ntpServerHost({host: this.ntpConfig.ntpAddress})
            .then(res => {
              if (res.code === 200) {
                this.$msg.success("ntp服务器地址修改成功！");
              } else {
                this.$msg.error("ntp服务器地址修改失败！");
              }
            });
      }
    },
		// VPN
		handleSwitchVPN(newValue) {
			console.log(newValue);
			console.log(this.transitionArgument(newValue));
			system_parameter_VPNState({
				vpnStatus: this.transitionArgument(newValue),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("VPN上报配置成功！");
				} else {
					this.$msg.error("VPN上报配置失败！");
				}
			});
		},
		handleSelect_VPN() {
			console.log(this.VPNConfig.VPNFrequency);
			console.log(this.transitionSelectTime(this.VPNConfig.VPNFrequency));
			system_parameter_VPN({
				vpnFrequency: this.transitionSelectTime(this.VPNConfig.VPNFrequency),
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("VPN发送频率修改成功！");
				} else {
					this.$msg.error("VPN发送频率修改失败！");
				}
			});
		},
		// 0/1 相互转换 true/false
		transitionArgument(value) {
			var returnValue;
			if (value === 0) {
				returnValue = true;
			} else if (value === 1) {
				returnValue = false;
			} else if (value === true) {
				returnValue = 0;
			} else if (value === false) {
				returnValue = 1;
			}
			return returnValue;
		},
		// 频率时间 相互转换 秒值
		transitionSelectTime(value) {
			var returnValue;
			switch (value) {
				case "5秒":
					returnValue = 5;
					break;
				case "10秒":
					returnValue = 10;
					break;
				case "30秒":
					returnValue = 30;
					break;
				case "60秒":
					returnValue = 60;
					break;
				case "5分钟":
					returnValue = 300;
					break;
				case "10分钟":
					returnValue = 600;
					break;
				case "30分钟":
					returnValue = 1800;
					break;
				case "1小时":
					returnValue = 3600;
					break;
				case "6小时":
					returnValue = 21600;
					break;
				case "12小时":
					returnValue = 43200;
					break;
				case "24小时":
					returnValue = 86400;
					break;
				case 5:
					returnValue = "5秒";
					break;
				case 10:
					returnValue = "10秒";
					break;
				case 30:
					returnValue = "30秒";
					break;
				case 60:
					returnValue = "60秒";
					break;
				case 300:
					returnValue = "5分钟";
					break;
				case 600:
					returnValue = "10分钟";
					break;
				case 1800:
					returnValue = "30分钟";
					break;
				case 3600:
					returnValue = "1小时";
					break;
				case 21600:
					returnValue = "6小时";
					break;
				case 43200:
					returnValue = "12小时";
					break;
				case 86400:
					returnValue = "24小时";
					break;
			}
			return returnValue;
		},
		// 查询所有的参数配置
		getAllParameter() {
			system_parameter_all().then((res) => {
				if (res.code == 200) {
					this.heartbeatConfig.heartbeatFrequency = this.transitionSelectTime(res.data.heartFrequency);
					this.requestConfig.requestFrequency = this.transitionSelectTime(res.data.requestFrequency);
					this.waringConfig.waringFrequency = this.transitionSelectTime(res.data.warningFrequency);
					this.waringConfig.waringState = this.transitionArgument(res.data.warningStatus);
					this.auditConfig.auditFrequency = this.transitionSelectTime(res.data.auditFrequency);
					this.auditConfig.auditState = this.transitionArgument(res.data.auditStatus);
					this.compareConfig.compareFrequency = this.transitionSelectTime(res.data.compareFrequency);
					this.compareConfig.compareState = this.transitionArgument(res.data.compareStatus);
					this.terminalMonitoringConfig.terminalMonitoringFrequency = this.transitionSelectTime(res.data.monitoringFrequency);
					this.terminalMonitoringConfig.terminalMonitoringState = this.transitionArgument(res.data.monitoringStatus);
					this.systemLogConfig.systemLogFrequency = this.transitionSelectTime(res.data.pcSyslogFrequen);
					this.systemLogConfig.systemLogState = this.transitionArgument(res.data.pcSyslogStatus);

					this.doorConfig.doorState = this.transitionArgument(res.data.devStatus);
					this.doorConfig.doorDistance = res.data.doorRange;
					this.doorConfig.attitudeError = res.data.angleRange;
					this.doorConfig.temperatureThreshold = res.data.temptureRange;
					this.doorConfig.humidityThreshold = res.data.rhRange;

					// this.VPNConfig.VPNFrequency = this.transitionSelectTime(res.data.vpnFrequency);
					this.VPNConfig.VPNFrequency = this.transitionSelectTime(86400);
					this.VPNConfig.VPNState = this.transitionArgument(res.data.vpnStatus);

					this.auditConfig.frequency = this.transitionArgument(res.data.frequency);

					this.doorConfig.cpuRange = res.data.cpuRange;
					this.doorConfig.diskRange = res.data.diskRange;
					this.doorConfig.memoryRange = res.data.memoryRange;
					this.doorConfig.cpuTemptureRange = res.data.cpuTemptureRange;
					this.doorConfig.frequency = this.transitionSelectTime(res.data.monitoringFrequency);
          this.smsConfig.smsState = (res.data.smsStatus === 0);
          this.smsConfig.smartAudit = (res.data.smartAudit === 0);
          this.ntpConfig.ntpAddress = res.data.ntpServerHost;
				}
			});
		},
	},
};
</script>
<style lang="less" scoped>
.strategyOverallContent {
	width: 100%;
	height: 100%;
	background: #ffffff;
	overflow: hidden;
	.systemParameterPageBox {
		width: 103%;
		height: 100%;
		padding: 12px 20px;
		box-sizing: border-box;
		background: #ffffff;
		overflow-y: scroll;
		.pageConfigBox {
			width: 100%;
			display: flex;
			flex-direction: column;
			justify-content: flex-start;
			align-items: flex-start;
			.pageConfigBoxTitle {
				width: 100%;
				height: 54px;
				border-bottom: 1px solid #eee;
				display: flex;
				flex-direction: row;
				justify-content: flex-start;
				align-items: center;
				.titleText {
					width: 145px;
					line-height: 36px;
					font-size: 16px;
					text-align: center;
					background: #eee;
				}
			}
			.pageConfigBoxContent {
				width: 100%;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: center;
				.pageConfigBoxContentItem {
					width: 90%;
					height: 68px;
					display: flex;
					flex-direction: row;
					justify-content: flex-start;
					align-items: center;
					.form_text {
						width: 172px;
						font-size: 16px;
					}
					.form_item {
						width: 24%;
						height: 40px;
						font-size: 16px;
						margin: 0 24px;
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
						/deep/ .el-select {
							width: 70%;
						}
					}
					.form_item_input {
						width: 24%;
						height: 40px;
						font-size: 16px;
						margin: 0 24px;
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						align-items: center;
						/deep/ .el-input {
							width: 70%;
						}
						[class*="wj-button-"] {
							font-size: 16px;
							padding: 10px 18px;
						}
					}
					.form_hint {
						width: 48%;
						height: 40px;
						margin-left: 18px;
						font-size: 14px;
						color: #363636;
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
					}
				}
			}
		}
	}
}
</style>
